import CryptoJS from 'crypto-js';

$.randomString = function randomString() {
    var len = 32;
    var chars = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678";
    var maxPos = chars.length;
    var ranString = '';
    for (let i = 0; i < len; i++) {
        ranString += chars.charAt(Math.floor(Math.random() * maxPos));
    }
    return ranString;
}

$.cryptSaltPsw = function cryptSaltPsw(salt, pwd) {
  var md5_pwd = CryptoJS.algo.MD5.create();
  md5_pwd.update(pwd);
  var md5 = CryptoJS.algo.MD5.create();
  md5.update(salt);
  md5.update(md5_pwd.finalize());
  return md5.finalize().toString();

}
